package com.hand.entity;

/**
 * Created by 86136 on 2019/7/18.
 */
public class Pagination {
    //总记录
    private int totalRecord;
    //当前页
    private int currentPage;
    //每页数量
    private int pageSize;
    //总页数
    private int totalPage;

    private int offSet;

    public int getTotalRecord() {

        return totalRecord;
    }

    public void setTotalRecord(int totalRecord) {

        this.totalRecord = totalRecord;
    }

    public int getCurrentPage() {

        return currentPage;
    }

    public void setCurrentPage(int currentPage) {

        this.currentPage = currentPage;
    }

    public int getPageSize() {

        return pageSize;
    }

    public void setPageSize(int pageSize) {

        this.pageSize = pageSize;
    }

    public int getTotalPage() {

        if (totalRecord < 1) {

            totalPage = 0;
            return totalPage;
        }
        totalPage = (getTotalRecord() - 1) / getPageSize() + 1;
        return totalPage;
    }

    public int getOffSet() {

        offSet = (getCurrentPage() - 1) * getPageSize();
        return offSet;
    }

    public boolean isFirstPage() {

        if (this.currentPage <= 1) {

            return true;
        }
        return false;
    }

    public boolean isLastPage() {

        if (this.currentPage >= this.totalPage) {

            return true;
        }
        return false;
    }
}
